﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;

namespace Shop.Common
{
    public class HandleLog
    {
        #region 获取客户端的IP地址
        public static string GetIPAddress()
        {
            //获取代理后的真实IP
            string ClientIP = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            //判断是否已经取得IP，如果没有则表示没有用代理或其它问题
            if (string.IsNullOrEmpty(ClientIP))
            {
                //直接获取IP
                ClientIP = System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
            }
            return ClientIP;
        }
        #endregion
    }
}